package getBaiduPaid;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

import batch.Mysqlconn;

public class Config {
	public static String Query = "http://www.baidu.com/s?wd=";
	
	public static Mysqlconn conn = new Mysqlconn();
	public static String user;
	public static String password;
	public static String DB;
	public static String Table;
	public static String TableKeywordQ;
	public static ResultSet rs;
	public static Statement stm;
	public static Statement stm_KeywordQ;
	
	public static Properties p = new Properties();
	
	public static Date date = new Date();
	public static DateFormat df;
	
	public static String VisitStatucCol = "visited";
	public static String LeftOrRight;
	public static String keywordList;

	public static String todoList;	
	public static File todoListFileOb;
	
	public static int  batch;
	
	public static void Init () throws FileNotFoundException, IOException, ClassNotFoundException, SQLException {
		p.load(new FileInputStream(new File("./GetBaiduRanking.config")));
		
		user = p.getProperty("user");
		password = p.getProperty("password");
		DB = p.getProperty("db");
		Table = p.getProperty("table_prefix")+p.getProperty("left_or_right");
		TableKeywordQ = p.getProperty("table_KeywordQ");
		keywordList = p.getProperty("inputFileName");
		todoList = p.getProperty("todoList");
		LeftOrRight = p.getProperty("left_or_right");
		
		stm_KeywordQ = conn.Connect(DB, TableKeywordQ, user, password).createStatement();
		stm = conn.Connect(DB, Table, user, password).createStatement();
		df = new SimpleDateFormat("YYYY/MM/dd");
		
		batch = Integer.parseInt(p.getProperty("batch"));
		todoListFileOb = new File(todoList);
	}
}
